/**
 *
 * @param table {Table}
 * @param uninstall {boolean} 是否在生成代码时注释该方法，用于备用
 * @returns {string}
 */
const markDeleteById = (table, uninstall = false) => {
  const {names: {JavaName}} = table
  return `// <-
  /**
   * 按 encryptId 逻辑删除
   * @param encryptId {string} {@link ${JavaName}#encryptId}
   * @return {Promise<Result>}
   */
  static async markDeleteById(encryptId) {
    return await http
      .patch(markDeleteByIdURL.format(encryptId || 0))
      .then(Result.ofResponse)
      .catch(Result.ofCatch)
  }
  /**
   * 按 encryptId 批量逻辑删除
   * @param encryptIds {string[]} {@link ${JavaName}#encryptId}
   * @return {Promise<Result>}
   */
  static async markDeleteByIds(encryptIds) {
    return await http
      .patch(markDeleteByIdsURL, encryptIds)
      .then(Result.ofResponse)
      .catch(Result.ofCatch)
  }
`.split('\n')
    .map(row => (uninstall ? '//' : '') + row)
    .join('\n')
}
export const markDeleteByIdInstall = table => markDeleteById(table)
export const markDeleteByIdUninstall = table => markDeleteById(table, true)
